# -*- coding: utf-8 -*-
# from __future__ import unicode_literals

from django.db import models

from tags.models import Tags

# Create your models here.


class BlogType(models.Model):
    """
    博客类别表
    """
    type_name = models.CharField(max_length=12, null=False, unique=True, verbose_name=u'博客类型')
    count = models.IntegerField(default=0, verbose_name=u'该类型统计总数')
    crate_time = models.DateTimeField(auto_now_add=True, verbose_name=u'创建时间')

    def __unicode__(self):
        return self.type_name

    class Meta:
        verbose_name = u'博客类型'
        verbose_name_plural = verbose_name
        db_table = 'blog_type'


class BlogMsg(models.Model):
    """
    博客信息表
    """
    title = models.CharField(max_length=64, null=False, verbose_name=u'博客标题')
    create_time = models.DateTimeField(auto_now_add=True, verbose_name=u'创建时间')
    update_time = models.DateTimeField(auto_now=True, verbose_name=u'最近一次更新时间')
    is_public = models.IntegerField(choices=((0, u'公开'), (1, u'私有')), verbose_name=u'是否公开')
    blog_type = models.ForeignKey(BlogType, verbose_name=u'博客类型')
    blog_tags = models.ManyToManyField(Tags, null=True, verbose_name=u'包含标签')
    blog_content = models.TextField(verbose_name=u'博客内容')
    views = models.IntegerField(default=0, verbose_name=u'浏览量')
    like_it = models.IntegerField(default=0, verbose_name=u'收藏数')
    title_image = models.URLField(default=None, null=True, verbose_name=u'标题图片')

    def __unicode__(self):
        return self.title

    class Meta:
        verbose_name = u'博客'
        verbose_name_plural = verbose_name
        db_table = "blog_msg"
